package com.tiantianyuegou.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.trouble.framework.adapter.BaseAdapterHelper;
import com.trouble.framework.adapter.QuickAdapter;
import com.tiantianyuegou.R;
import com.tiantianyuegou.model.ProductImgeModel;

import java.util.List;

/**
 * Created by ivany on 2016/1/20.
 */
public class ProductDespAdapter extends QuickAdapter<ProductImgeModel> {


    public ProductDespAdapter(Context context) {
        super(context, R.layout.item_product_desp_img);
    }

    public void setData(List<ProductImgeModel> datas) {
        data.clear();
        data.addAll(datas);
    }

    @Override
    protected void convert(BaseAdapterHelper baseAdapterHelper, ProductImgeModel productDespImg) {
        ImageView imageView = baseAdapterHelper.getView(R.id.item_product_desp_img);
        if (productDespImg.getBitmap() != null) {
            imageView.setImageBitmap(productDespImg.getBitmap());
        } else {
            ImageLoader.getInstance().displayImage(productDespImg.getUrl(), imageView);
        }
    }
}
